import React, { Component } from 'react'

import { connect } from 'react-redux';

import { changeUTitle } from '../../actions/ui';

import CartItem from './CartItem';

import './Cart.less';

const mapState = state => {
  return {
    cartList: state.cart.list
  }
}

@connect(mapState, { changeUTitle })

export default class Cart extends Component {
  componentDidMount() {
    this.props.changeUTitle('购物车');
  }
  render() {
    return (
      <div>
        <ul className="wgd-cart">
          {
            this.props.cartList.map(cart => {
              return <CartItem key={cart.id} {...cart}/>
            })
          }
        </ul>
      </div>
    )
  }
}
